import { usePageRequest } from "../../../utils/request";
import dayjs from '../../../utils/day'

Component({
    data: {
        message: ''
    },
    methods: {
        onLoad() {
            this.request = new usePageRequest('api/searchstrategylist', {
                pretreatment: data => {
                    data.list = data.list.map(item => {
                        item.time = dayjs.unix(item.create_time).format('YYYY-MM-DD')
                        return item
                    })
                    return data
                }
            }, this)
        },
        onShow() {
            this.getTabBar().init();
        },
        onReachBottom() {
            this.request.next()
        },
        async onPullDownRefresh() {
            this.setData({
                message: ''
            })
            await this.request.reset({})
            wx.stopPullDownRefresh()
        },
        async search() {
            await this.request.reset({
                title: this.data.message
            })
        }
    }
})
